function result_su(data, msg) {
	let dataValue = [],
		codeValue = 200,
		msgValue = "数据操作成功！"
	if (data) {
		dataValue = data
	}
	if (msg) {
		msgValue = msg
	}
	return {
		code: codeValue,
		data: dataValue,
		msg: msgValue
	}
}

function getUuid() {
	let d = new Date().getTime();
	return 'xxxxxxyxxxxxxxxxxxyxxxxx'.replace(/[xy]/g, function(c) {
		let r = (d + Math.random() * 16) % 16 | 0;
		d = Math.floor(d / 16);
		return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
	});
}

function get_dd_no() {
	let dateVal = new Date()
	let uuid = "DD"
	let year = dateVal.getFullYear()
	let month = dateVal.getMonth() + 1
	let day = dateVal.getDate()
	let hours = dateVal.getHours() + 8
	let minutes = dateVal.getMinutes()
	let seconds = dateVal.getSeconds()
	let dateStr = "" + year + "" + (month > 10 ? month : ("0" + month)) + "" + (day > 10 ? day : ("0" + day)) + "" +
		(hours >
			10 ? hours : ("0" + hours)) + "" + (minutes > 10 ? minutes : ("0" + minutes)) + "" + (seconds > 10 ?
			seconds : (
				"0" + seconds))
	uuid = uuid + dateStr
	let sum = 20 - uuid.length
	for (let i = 0; i < sum; i++) {
		uuid = uuid + Math.floor(Math.random() * 10)
	}
	return uuid
}

function get_material_dd_no() { //获取订单标识
	let dateVal = new Date()
	let uuid = "WL"
	let year = dateVal.getFullYear()
	let month = dateVal.getMonth() + 1
	let day = dateVal.getDate()
	let hours = dateVal.getHours() + 8
	let minutes = dateVal.getMinutes()
	let seconds = dateVal.getSeconds()
	let dateStr = "" + year + "" + (month > 10 ? month : ("0" + month)) + "" + (day > 10 ? day : ("0" + day)) + "" +
		(hours >
			10 ? hours : ("0" + hours)) + "" + (minutes > 10 ? minutes : ("0" + minutes)) + "" + (seconds > 10 ?
			seconds : (
				"0" + seconds))
	uuid = uuid + dateStr
	let sum = 20 - uuid.length
	for (let i = 0; i < sum; i++) {
		uuid = uuid + Math.floor(Math.random() * 10)
	}
	return uuid
}

function get_qid_no() {
	let dateVal = new Date()
	let uuid = "QID"
	let year = dateVal.getFullYear()
	let month = dateVal.getMonth() + 1
	let day = dateVal.getDate()
	let hours = dateVal.getHours() + 8
	let minutes = dateVal.getMinutes()
	let seconds = dateVal.getSeconds()
	let dateStr = "" + year + "" + (month > 10 ? month : ("0" + month)) + "" + (day > 10 ? day : ("0" + day)) + "" +
		(hours >
			10 ? hours : ("0" + hours)) + "" + (minutes > 10 ? minutes : ("0" + minutes)) + "" + (seconds > 10 ?
			seconds : (
				"0" + seconds))
	uuid = uuid + dateStr
	let sum = 32 - uuid.length
	for (let i = 0; i < sum; i++) {
		uuid = uuid + Math.floor(Math.random() * 10)
	}
	return uuid
}

function get_vip_card_no() {
	let dateVal = new Date()
	let uuid = "VIP"
	let year = dateVal.getFullYear()
	let month = dateVal.getMonth() + 1
	let day = dateVal.getDate()
	let hours = dateVal.getHours() + 8
	let minutes = dateVal.getMinutes()
	let seconds = dateVal.getSeconds()
	let dateStr = "" + year + "" + (month > 10 ? month : ("0" + month)) + "" + (day > 10 ? day : ("0" + day)) + "" +
		(hours >
			10 ? hours : ("0" + hours)) + "" + (minutes > 10 ? minutes : ("0" + minutes)) + "" + (seconds > 10 ?
			seconds : (
				"0" + seconds))
	uuid = uuid + dateStr
	let sum = 32 - uuid.length
	for (let i = 0; i < sum; i++) {
		uuid = uuid + Math.floor(Math.random() * 10)
	}
	return uuid
}

/**
 * 获取wmz平台支付商户订单号
 */
function get_out_trade_no_wmz() {
	let dateVal = new Date()
	let uuid = "wmz"
	let year = dateVal.getFullYear()
	let month = dateVal.getMonth() + 1
	let day = dateVal.getDate()
	let hours = dateVal.getHours() + 8
	let minutes = dateVal.getMinutes()
	let seconds = dateVal.getSeconds()
	let dateStr = "" + year + "" + (month > 10 ? month : ("0" + month)) + "" + (day > 10 ? day : ("0" + day)) + "" +
		(hours >
			10 ? hours : ("0" + hours)) + "" + (minutes > 10 ? minutes : ("0" + minutes)) + "" + (seconds > 10 ?
			seconds : (
				"0" + seconds))
	uuid = uuid + dateStr
	let sum = 32 - uuid.length
	for (let i = 0; i < sum; i++) {
		uuid = uuid + Math.floor(Math.random() * 10)
	}
	return uuid
}

function get_order_no_lakala(lakalaId) {
	let dateVal = new Date()
	let uuid = "QID"
	if(lakalaId){
		uuid = lakalaId
	}
	let year = dateVal.getFullYear()
	let month = dateVal.getMonth() + 1
	let day = dateVal.getDate()
	let hours = dateVal.getHours() + 8
	let minutes = dateVal.getMinutes()
	let seconds = dateVal.getSeconds()
	let dateStr = "" + year + "" + (month > 10 ? month : ("0" + month)) + "" + (day > 10 ? day : ("0" + day)) + "" +
		(hours >
			10 ? hours : ("0" + hours)) + "" + (minutes > 10 ? minutes : ("0" + minutes)) + "" + (seconds > 10 ?
			seconds : (
				"0" + seconds))
	uuid = uuid + dateStr
	let sum = 32 - uuid.length
	for (let i = 0; i < sum; i++) {
		uuid = uuid + Math.floor(Math.random() * 10)
	}
	return uuid
}

function get_no() {
	let dateVal = new Date()
	let uuid = ""
	let year = dateVal.getFullYear()
	let month = dateVal.getMonth() + 1
	let day = dateVal.getDate()
	let hours = dateVal.getHours() + 8
	let minutes = dateVal.getMinutes()
	let seconds = dateVal.getSeconds()
	let dateStr = "" + year + "" + (month > 10 ? month : ("0" + month)) + "" + (day > 10 ? day : ("0" + day)) + "" +
		(hours >
			10 ? hours : ("0" + hours)) + "" + (minutes > 10 ? minutes : ("0" + minutes)) + "" + (seconds > 10 ?
			seconds : (
				"0" + seconds))
	uuid = uuid + dateStr
	let sum = 32 - uuid.length
	for (let i = 0; i < sum; i++) {
		uuid = uuid + Math.floor(Math.random() * 10)
	}
	return uuid
}

/**
 * 12个字符的随机字符串
 */
function get_nonceStr12() {
	let uuid = ""
	for (let i = 0; i < 12; i++) {
		uuid = uuid + Math.floor(Math.random() * 10)
	}
	return uuid
}

module.exports = {
	result_su,
	getUuid,
	get_dd_no,
	get_material_dd_no,
	get_qid_no,
	get_vip_card_no,
	get_out_trade_no_wmz,
	get_order_no_lakala,
	get_no,
	get_nonceStr12
}
